home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Hardware / Mac OS USB DDK / Mac OS USB DDK 1.4.1 / Examples / USBSampleStorageDriver / UnitTableDriver / USB_StdCommands.h < prev   
Encoding:
C/C++ Source or Header  |  2000-04-25  |  5.4 KB  |  181 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        DAM_StdCommands.h
  3.  
  4.     Contains:    All builder routines for SCSI CDBs.
  5.  
  6.     Version:    1.0
  7.  
  8.     Copyright:    © 1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12. #pragma once
  13.  
  14. #include "USB_ClassDriverAccess.h"
  15.  
  16. enum 
  17. {
  18.     // Standard Command Opcodes
  19.     kCmdFormat                     = 0x04,
  20.     kCmdInquiry                 = 0x12,
  21.     kCmdModeSelect                 = 0x55,
  22.     kCmdModeSense6                 = 0x1A,
  23.     kCmdModeSense10             = 0x5A,
  24.     kCmdPreventAllowRemoval     = 0x1E,
  25.     kCmdRead                     = 0x28,
  26.     kCmdReadCapacity             = 0x25,
  27.     kCmdReadFormatCapacities     = 0x23,
  28.     kCmdRequestSense             = 0x03,
  29.     kCmdRezero                     = 0x01,
  30.     kCmdSeek                     = 0x2B,
  31.     kCmdSendDiagnostic             = 0x1D,
  32.     kCmdStartStopUnit             = 0x1B,
  33.     kCmdTestUnitReady             = 0x00,
  34.     kCmdWrite                     = 0x2A,
  35.     kCmdWriteVerify             = 0x2E,
  36.     kCmdVerify                     = 0x2F
  37. };
  38.  
  39. // Command set specifiers
  40. enum
  41. {
  42.     kRBCCommand = 0,
  43.     kSPCCommand
  44. };
  45.  
  46. #pragma mark -
  47. #pragma mark Definitions for the Inquiry command
  48. // Inquiry Peripheral Qualifier
  49. enum
  50. {
  51.     kInqPeripheralConnected                    = 0x00,
  52.     kInqPeripheralSupportedButNotConnected    = 0x20,
  53.     kInqPeripheralNotSupported                = 0x60,
  54.     kInqPeripheralQualifierMask                = 0xE0
  55. };
  56.  
  57. // Inquiry Peripheral Device types
  58. enum
  59. {
  60.     kInqDirectAccessSBCDevice                = 0x00,
  61.     kInqSequentialAccessSSCDevice            = 0x01,
  62.     kInqPrinterSSCDevice                    = 0x02,
  63.     kInqProcessorSPCDevice                    = 0x03,
  64.     kInqWriteOnceSBCDevice                    = 0x04,
  65.     kInqCDROM_MMCDevice                        = 0x05,
  66.     kInqScannerSCSI2Device                    = 0x06,
  67.     kInqOpticalMemorySBCDevice                = 0x07,
  68.     kInqMediumChangerSMCDevice                = 0x08,
  69.     kInqCommunicationsSSCDevice                = 0x09,
  70.     /* 0x0A - 0x0B ASC IT8 Graphic Arts Prepress Devices */
  71.     kInqStorageArrayControllerSCC2Device    = 0x0C,
  72.     kInqEnclosureServicesSESDevice            = 0x0D,
  73.     kInqSimplifiedDirectAccessRBCDevice        = 0x0E,
  74.     kInqOpticalCardReaderOCRWDevice            = 0x0F,
  75.     /* 0x10 - 0x1E Reserved Device Types */
  76.     kInqUnknownOrNoDeviceType                = 0x1F,
  77.     
  78.     kInqPeripheralDeviceTypeMask            = 0x1F
  79. };
  80.  
  81. // Inquiry Removable Bit Mask
  82. enum
  83. {
  84.     kInqRemovableMask                         = 0x80,
  85.     kInqANSIVersionMask                        = 0x07
  86. };
  87.  
  88. //
  89. // Sizes for some of the inquiry data fields
  90. //
  91. enum
  92. {
  93.     kVendorIDLen    = 8,
  94.     kProductIDLen    = 16,
  95.     kProductRevLen    = 4
  96. };
  97.  
  98. struct StandardInquiryData
  99. {
  100.     UInt8        qualifierAndType;                    // 7-5 = Qualifier. 4-0 = Device type.
  101.     UInt8        removableBit;                        // 7 = removable
  102.     UInt8        version;                            // 7/6 = ISO/IEC, 5-3 = ECMA, 2-0 = ANSI.
  103.     UInt8        responseData;                        // 7 = AERC, 6 = Obsolete, 5 = NormACA, 4 = HiSup 3-0 = Response data format.
  104.                                                     // If ANSI Version = 0, this is ATAPI and bits 7-4 = ATAPI version.
  105.     UInt8        additionalLength;                    // Number of additional bytes available in inquiry data
  106.     UInt8        SCCSReserved;                        // SCC-2 device flag and reserved fields
  107.     UInt8        flags1;                                // First byte of support flags
  108.     UInt8        flags2;                                // Second byte of support flags
  109.     char        vendorID[kVendorIDLen];                // Vendor ID in ascii
  110.     char        productID[kProductIDLen];            // Product ID in ascii
  111.     char        productRevision[kProductRevLen];    // Product revision in ascii
  112. };
  113. typedef struct StandardInquiryData StandardInquiryData;
  114. typedef StandardInquiryData* StandardInquiryDataPtr;
  115.  
  116. #pragma mark -
  117. #pragma mark Definitions for the Mode Sense/Select commands
  118. // Values for PreventAllowRemoval command
  119. enum
  120. {
  121.     kMode6ParameterHeaderLength            = 0x04,
  122.     kMode10ParameterHeaderLength        = 0x08,
  123.     kRBCDeviceParametersModePageCode     = 0x06,        // Per RBC
  124.     kRBCDeviceParametersModePageLength     = 0x0B,        // Per RBC
  125.     
  126.     kAllModePages = 0x3F
  127. };
  128.  
  129. #pragma mark -
  130. #pragma mark Definitions for the Prevent Allow Removal command
  131. // Values for PreventAllowRemoval command
  132. enum
  133. {
  134.     kPreventMediaRemoval = true,
  135.     kAllowMediaRemoval = false
  136. };
  137.  
  138. #pragma mark -
  139. #pragma mark Definitions for the StartStop command
  140. // Values for StartStopEject command
  141. enum
  142. {
  143.     kStartDevice = true,
  144.     kStopDevice = false,
  145.     kEjectMedia = true,
  146.     kDontEjectMedia = false
  147. };
  148.  
  149. #pragma mark -
  150. #pragma mark Definitions for the Read Capacity command
  151. typedef struct ReadCapacityData 
  152. {
  153.     UInt32        TotalBlocksOnMedia;            // Total number of blocks
  154.     UInt32        BlockLengthInBytes;            // Block length in bytes
  155. } ReadCapacityData, *ReadCapacityDataPtr;
  156.  
  157. #pragma mark -
  158. #pragma mark Definitions for the Request Sense command command
  159. // The Sense data that all devices should support
  160. enum 
  161. {
  162.     kSenseStandardDataSize = 18
  163. };
  164.  
  165. #pragma mark -
  166. #pragma mark Prototypes for Command Builder Routines
  167. // ATAPI/SCSI-2 Device Commands used internally
  168. extern OSStatus     ModeSenseBuilder( IntDriveRequestPBPtr requestPB, UInt8 CommandSet, UInt8 *Buffer, UInt8 modePage, UInt8 numBytes );
  169. extern OSStatus     SendDiagnosticBuilder( IntDriveRequestPBPtr requestPB );
  170. extern OSStatus     TestUnitReadyBuilder( IntDriveRequestPBPtr requestPB );
  171. extern OSStatus        RequestSenseBuilder( IntDriveRequestPBPtr requestPB, Ptr senseData );
  172. extern OSStatus     InquiryBuilder(IntDriveRequestPBPtr requestPB, UInt8 *Buffer, UInt8 InqDataLength);
  173. extern OSStatus     GetMediaGeometryBuilder( IntDriveRequestPBPtr requestPB, ReadCapacityData *getGeometry );
  174. extern OSStatus     ReadFormatCapacityBuilder( IntDriveRequestPBPtr requestPB, UInt8 *Buffer, UInt8 numBytes );
  175. extern OSStatus     StartStopEjectCartridgeBuilder(IntDriveRequestPBPtr requestPB, Boolean StartDrive, Boolean doEject);
  176. extern OSStatus     PreventAllowRemovalBuilder( IntDriveRequestPBPtr requestPB, Boolean preventRemoval );
  177. extern OSStatus     FormatFloppyTrackBuilder( IntDriveRequestPBPtr requestPB, UInt8 *Buffer, UInt32 FormatCapacity, UInt16 blockSize, UInt8 TrackNum, UInt8 Side);
  178.  
  179. // Routines used for processing data from the commands
  180. extern void FixRequestSenseData( IntDriveRequestPBPtr requestPB );
  181.